<?php include("conn.php");
mysql_query('SET NAMES UTF8');

$query=mysql_query("SELECT  DISTINCT fTitle  FROM goodsselect WHERE goodsid='".$_REQUEST[goodsid]."'");

$prize=array();
while ($result=mysql_fetch_assoc($query)) {

	$sonSelects = mysql_query("SELECT selectid,sTitle as name,number as num, price FROM goodsselect WHERE goodsid='".$_REQUEST[goodsid]."'  AND  fTitle='".$result[fTitle]."'");

	$sonSelectArry = array();

	while ($sonSelect=mysql_fetch_assoc($sonSelects)) {

		  $result['num'] = $sonSelect['num'];
		  $result['price'] = $sonSelect['price'];
		  $result['selectid'] = $sonSelect['selectid'];

		   if(!$sonSelect['name']){
		   	    $result['data'] = $sonSelectArry;
	            $prize[] = $result;
                $ret  = array('code' => 200,'data' => $prize);
                echo json_encode($ret);
                exit();
		   }
		  
          $sonSelectArry[] = $sonSelect;
	}

	// var_dump($sonSelectArry);die;
	$result['data'] = $sonSelectArry;
	$prize[] = $result;

}
$ret  = array('code' => 200,'data' => $prize);
echo json_encode($ret);

?>